<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="../../../css/reset.css" />
		<link rel="stylesheet" type="text/css" href="login.css" />
		<link rel="stylesheet" type="text/css" href="../../../../common/footer/footer.css"/>
		<title></title>
		<script src="../../../js/jquery-2.2.3.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../../js/flexible.min.js" type="text/javascript" charset="utf-8"></script>
		<!--cookie 操作插件-->
		<script src="../../../js/jquery.cookie.js"></script>
		<style type="text/css">
			input {
				border: 0;
				outline: none;
			}
		</style>
	</head>

	<body>
		<div class="wrapper">
			<div id="logo"><img src="../../../images/login/logo.png" /></div>
			<div class="section sectionF" style="border: 1px solid #c7c7c7; border-radius: 1.111111rem;">
				<div></div>
				<div><img src="../../../images/login/ico_sign_01.png" /><input type="text" name="" id="user" value="" placeholder="手机号" /></div>
				<div></div>
			</div>
			<div class="section sectionF" style="border: 1px solid #c7c7c7; border-radius: 1.111111rem;">
				<div></div>
				<div><img src="../../../images/login/ico_sign_02.png" /><input type="password" name="" id="pwd" value="" placeholder="密码" /></div>
				<div></div>
			</div>
			<div class="section">
				<a href="#" id="login">
					<div></div>
					<div id="loginBtn">
						<p><span>登</span><span>录</span></p>
					</div>
					<div></div>
				</a>
			</div>
			<div class="group">
				<a href="../register/forgetPassWord.html">忘记密码</a>
				<a href="../register/mynews.html">立即注册</a>
			</div>
			
		</div>
		<script type="text/javascript">
			$(function() {
				console.log($.cookie('tokenRh'));
				var local = 'http://47.104.13.109/member-service';
				$("#loginBtn").on("click", function() {
					var uPattern1 = /^[a-zA-Z0-9]{4,16}$/;
					var uPattern2 = /^[A-Za-z]+[0-9]+[A-Za-z0-9]*|[0-9]+[A-Za-z]+[A-Za-z0-9]*$/g;
					if(!uPattern1.test($("#user").val())) {
						return alert("手机号格式错误");
					}
					//					if (!uPattern2.test($("#pwd").val())) {
					//						return alert("密码必须由6~16个英文字母和数字的字符串组成！");
					//					}
					$.ajax({
						type: "get",
						url: local + '/auth/static-login',
						async: true,
						data: {
							'tel': $("#user").val(),
							'password': $("#pwd").val()
						},
						success: function(res) {
							console.log(res);
							if(res.islogin) {
								//								if($.cookie("tokenRh")){
								$.cookie('tokenReztApp', res.token, {
									expires: 7,
									path: '/'
								});
								$.cookie("tokenRh", res.token, {
									expires: 7,
									path: '/'
								});
								$.cookie('memberId', res.id, {
									expires: 7,
									path: '/'
								});
								$.cookie('roleId', res.roleList[0].id, {
									expires: 7,
									path: '/'
								});
								window.location.href = "../../kaoqin/index2.html";
							} else {
								alert("账号或密码错误！！！");
							}
						},
						error: function(error) {
							var errors = JSON.parse(error.responseText);
							console.log(errors)
							errors = errors.error_message.replace(":", "");
							alert(errors);
						}
					});
				})
			})
		</script>